/**
 *  @file UtilFuncT.h
 */
#ifndef _UTILFUNCT_H_
#define _UTILFUNCT_H_

#include "BaseObject.h"

namespace cppflib
{

/**
 *  Check if pObj can be casted to CLASSTYPE
 */
template <typename CLASSTYPE>
bool InstanceOf(BaseObject * pObj)
{
   CLASSTYPE *pTargetObj = dynamic_cast<CLASSTYPE*>(pObj);
   return (pTargetObj != NULL);
}

/**
 *  Check if const pObj can be casted to const CLASSTYPE
 */
template <typename CLASSTYPE>
bool InstanceOf(const BaseObject * pObj)
{
   const CLASSTYPE *pTargetObj = dynamic_cast<const CLASSTYPE*>(pObj);
   return (pTargetObj != NULL);
}

/**
 *  Return min of 2 values
 */
template <typename TYPE>
TYPE Min(TYPE a, TYPE b)
{
   return (a < b) ? a : b;
}

/**
 *  Return max of 2 values
 */
template <typename TYPE>
TYPE Max(TYPE a, TYPE b)
{
   return (a > b) ? a : b;
}


}  // namespace cppflib

#endif

 